package com.miracle.system.domain;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ：miracle.cui
 * @description：TODO
 * @date ：2020/8/19 18:08
 */
public class TreeEntity implements Serializable {

    /** 节点ID */
    private Integer id;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeEntity> children;

    public TreeEntity()
    {

    }

    public TreeEntity(SysResource resource)
    {
        this.id = resource.getResourceId();
        this.label = resource.getResourceName();
        this.children = resource.getChildren().stream().map(TreeEntity::new).collect(Collectors.toList());
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<TreeEntity> getChildren() {
        return children;
    }

    public void setChildren(List<TreeEntity> children) {
        this.children = children;
    }
}
